class Partnership < ActiveRecord::Base
  belongs_to  :user
  belongs_to  :photo
  belongs_to  :gallery
  belongs_to  :video
  belongs_to  :page
  validate    :only_two_entities_in_a_partnership

  def only_two_entities_in_a_partnership
    self.errors.add(:partnership, 'must have two and only two entities') if self.attribute_names.reject {|method| method unless method[-3..-1] == "_id" and self.send(method)}.length != 2
  end
end
